<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr1 = ["a", "b", "c", "d", "e", "f"];

      // 复制数组，循环复制，在过程中过滤掉不符合要求的元素
      function copyArr(arr, start, len) {
        let r = [];
        let end = start + len - 1;
        for (let i = 0; i < arr.length; i++) {
          if (i >= start && i <= end) {
            r.push(arr[i]);
          }
        }
        return r;
      }
      console.log(copyArr(arr1, 1, 4));
    </script>
  </body>
</html>
